package ynu.sxp.demoapp.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ynu.sxp.demoapp.entity.Business;
import ynu.sxp.demoapp.repository.BusinessRepository;
import ynu.sxp.demoapp.service.BusinessService;

import java.util.List;
import java.util.UUID;

@Service
public class BusinessServiceImpl implements BusinessService {
    private final BusinessRepository businessRepository;

    @Autowired
    public BusinessServiceImpl(BusinessRepository businessRepository) {
        this.businessRepository = businessRepository;
    }

    @Override
    public List<Business> getBusinessesByOrderTypeId(Integer orderTypeId) {
        return businessRepository.findByOrderTypeId(orderTypeId);
    }

    @Override
    public Business getBusinessById(UUID businessId) {
        return businessRepository.findById(businessId).orElse(null);
    }

    @Override
    public List<Business> getAllBusinesses() {
        return businessRepository.findAll(); // 获取所有商家信息
    }
}